/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author TUANNK
 */
@Entity
@Table(name = "mobile", catalog = "EJB_Demo", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Mobile.findAll", query = "SELECT m FROM Mobile m"),
    @NamedQuery(name = "Mobile.findByMobilecode", query = "SELECT m FROM Mobile m WHERE m.mobilecode = :mobilecode"),
    @NamedQuery(name = "Mobile.findByMobilename", query = "SELECT m FROM Mobile m WHERE m.mobilename = :mobilename"),
    @NamedQuery(name = "Mobile.findByPrice", query = "SELECT m FROM Mobile m WHERE m.price >= :min and m.price <= :max"),
    @NamedQuery(name = "Mobile.findByPic", query = "SELECT m FROM Mobile m WHERE m.pic = :pic")})
public class Mobile implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "mobilecode", nullable = false, length = 10)
    private String mobilecode;
    @Size(max = 50)
    @Column(name = "mobilename", length = 50)
    private String mobilename;
    @Column(name = "price")
    private Integer price;
    @Size(max = 150)
    @Column(name = "pic", length = 150)
    private String pic;

    public Mobile() {
    }

    public Mobile(String mobilecode) {
        this.mobilecode = mobilecode;
    }

    public String getMobilecode() {
        return mobilecode;
    }

    public void setMobilecode(String mobilecode) {
        this.mobilecode = mobilecode;
    }

    public String getMobilename() {
        return mobilename;
    }

    public void setMobilename(String mobilename) {
        this.mobilename = mobilename;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mobilecode != null ? mobilecode.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Mobile)) {
            return false;
        }
        Mobile other = (Mobile) object;
        if ((this.mobilecode == null && other.mobilecode != null) || (this.mobilecode != null && !this.mobilecode.equals(other.mobilecode))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Mobile[ mobilecode=" + mobilecode + " ]";
    }
    
}
